package com.drinking.springcloudprovider.controller;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ServiceController {

    @RequestMapping("/")
    public String Hello(){
        return "这是服务提供者服务器的主页。";
    }

    @RequestMapping("/test")
    public String test(){
        return "来自于服务提供者的测试数据";
    }

    @RequestMapping("/test02")
    public String test02(){
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "来自于服务提供者的3s延迟测试数据";
    }

    @RequestMapping("/test03")
    public String test03(){
        int i = 10/0;
        return "抛出异常的数据";
    }

    @RequestMapping("/test/{id}/{name}")
    public String test(@PathVariable String id, @PathVariable String name){
        return "{id='"+id+"',name='"+name+"'}";
    }

    @RequestMapping("/test04")
    public String test04(@RequestParam String id, @RequestParam String name){
        return "{id='"+id+"',name='"+name+"'}";
    }

}
